/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Tables;

import Domain.Activity;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Min0
 */
public class BookingActivityTableModel extends DefaultTableModel
{

    private ArrayList<Activity> data;

    public BookingActivityTableModel()
    {
        data = new ArrayList<Activity>();
    }

    @Override
    public boolean isCellEditable(int row, int column)
    {
        return false;
    }

    public void setData(ArrayList<Activity> data)
    {
        this.data = data;
    }

    public ArrayList<Activity> getData()
    {
        return data;
    }

    @Override
    public int getColumnCount()
    {
        return 5;
    }

    @Override
    public int getRowCount()
    {
        if (data == null)
        {
            return 0;
        } else
        {
            return data.size();
        }
    }

    @Override
    public String getColumnName(int column)
    {
        String columnName = "";
        switch (column)
        {
            case 0:
                columnName = "ActivityID";
                break;
            case 1:
                columnName = "Activity";
                break;
            case 2:
                columnName = "SportFacilityNo";
                break;
            case 3:
                columnName = "Date";
                break;
            case 4:
                columnName = "Time";
                break;
        }
        return columnName;
    }

    @Override
    public Object getValueAt(int row, int column)
    {
        Object value = null;
        switch (column)
        {
            case 0:
                value = data.get(row).getActivityID();
                break;
            case 1:
                value = data.get(row).getActivity();
                break;
            case 2:
                value = data.get(row).getSportFacilityNo();
                break;
            case 3:
                value = data.get(row).getDate();
                break;
            case 4:
                value = data.get(row).getTime();
                break;
        }

        return value;
    }
}
